// 版权归陈超所有


#include "AbilitySystem/ModMagCalculation/MMC_MaxMana.h"

#include "AbilitySystem/CC_AttributeSet.h"
#include "Interations/CC_CombatInterface.h"

UMMC_MaxMana::UMMC_MaxMana()
{
	IntelligenceDef.AttributeToCapture = UCC_AttributeSet::GetIntelligenceAttribute();
	IntelligenceDef.AttributeSource = EGameplayEffectAttributeCaptureSource::Target;
	IntelligenceDef.bSnapshot = false;
}

float UMMC_MaxMana::CalculateBaseMagnitude_Implementation(const FGameplayEffectSpec& Spec) const
{
	/*1. 获取Intelligence */
	FAggregatorEvaluateParameters EvaluateParameters;
	EvaluateParameters.SourceTags = Spec.CapturedSourceTags.GetAggregatedTags();
	EvaluateParameters.TargetTags = Spec.CapturedTargetTags.GetAggregatedTags();

	float Intelligence = 1.f;
	GetCapturedAttributeMagnitude(IntelligenceDef, Spec, EvaluateParameters, Intelligence);
	Intelligence = FMath::Max<float>(Intelligence, 0.f);

	/*2. 获取Level */
	ICC_CombatInterface* CombatInterface = Cast<ICC_CombatInterface>(Spec.GetContext().GetSourceObject());
	int32 CharacterLevel = CombatInterface->GetCharacterLevel();

	/*3. 计算公式*/
	return (50.f + Intelligence * 2.5f + CharacterLevel * 5.f);

}
